local skill = fk.CreateSkill{
  name = "tea__zhaoluan",
  tags = { Skill.Compulsory, }
}
---@type TrigSkelSpec<TrigFunc>
local zhaoluan = {
mute = true,
  can_trigger = function(self, event, target, player, data)
    return (event == fk.GameStart and player:hasSkill(self)) or (event == fk.Deathed and target == player and player:hasSkill(self, false, true))
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targets = room.alive_players

    if event == fk.GameStart then 
      player:broadcastSkillInvoke(skill.name, 1)
    else
      player:broadcastSkillInvoke(skill.name, 2)
    end
    room:notifySkillInvoked(player, skill.name, "big")

    room:sortByAction(targets)
    local card = Fk:cloneCard("slash")
    for _, p in ipairs(targets) do
      local can_cancel = table.find(p:getCardIds("he"), function(cid)
        return not p:prohibitDiscard(cid)
      end) and not p:isNude()
      local can_choose = can_cancel or (p:canUse(card, {bypass_distances = true}) and table.find(room:getOtherPlayers(p), function(p2)
        return p:canUseTo(card, p2, {bypass_distances = true})
      end))
      if not p.dead and can_choose  then
        local use = room:askToUseCard(p, {
          skill_name = skill.name,
          cancelable = can_cancel,
          pattern = "slash",
          prompt = "#tea__zhaoluan-use",
          extra_data = {
            extraUse = true,
            bypass_distances = true,
          },
          extraUse = true,
        })
        if use then
          room:useCard(use)
        else
          room:askToDiscard(p, {
            min_num = 1,
            max_num = 1,
            skill_name = skill.name,
            cancelable = false,
            prompt = "#tea__zhaoluan-discard",
            include_equip = true,
          })
        end
      end
    end
  end,
}
skill:addEffect(fk.GameStart, zhaoluan)
skill:addEffect(fk.Deathed, zhaoluan)
return skill